﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HRM.Common;
using System.Data;

namespace HRM.Controller
{
    public class HeThong_Controller : Standard_Controller
    {
        #region "Contructor"
        private static HeThong_Controller _instance;
        protected HeThong_Controller() { }
        protected void Dispose()
        {
            _instance = null;
        }
        private static object _syncLock = new object();
        public static HeThong_Controller Instance()
        {
            if (_instance == null)
            {
                lock (_syncLock)
                {
                    if (_instance == null)
                        _instance = new HeThong_Controller();
                }
            }
            return _instance;
        }
        public static HeThong_Controller Instance(String transName)
        {
            if (!String.IsNullOrEmpty(transName))
            {
                HeThong_Controller _instanceTrans = new HeThong_Controller();
                _instanceTrans.Trans_Name = transName;
                return _instanceTrans;
            }
            else
                return Instance();
        }
        #endregion


        public void SaveLog(string username, string computer)
        {
             DataConnect.ExecuteNonQuery(DataConnect.WorkingConnect, Procedure_Name("", "HRM_Log_SaveLog", false)
                ,username
                , computer
            );
        }

        public int GetVersion(ref string sDescription)
        {
            DataRowEx dr = DataConnect.ExecuteRow(DataConnect.WorkingConnect, Procedure_Name("", "HRM_GetVersion", false));
            sDescription = dr.GetValue<string>("Description");
            return dr.GetValue<int>("Version");
        }
    }
}
